package com.suxii.utils;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.suxii.Thread.NettyThread;
import com.suxii.pojo.MessageMsg;
import com.suxii.service.MyNettyService;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Global extends Application {
    public static Integer uid=0;
    public static Integer uuid=0;

    public static String name;

    public static Integer noticeUid=0;

    // TODO 当前全局变量线程不安全，app销毁会使变量值为初始化
    public static Integer getUid() {
        return uid;
    }

    public static void setUid(Integer uid) {
        Global.uid = uid;
    }

    public static Integer getUuid() {
        return uuid;
    }

    public static void setUuid(Integer uuid) {
        Global.uuid = uuid;
    }

    public static Context context;

    public static Context getContext() {
        return context;
    }

    public static void setContext(Context context) {
        Global.context = context;
    }

    // 消息列表
    public static List<MessageMsg> messageMsgList;

    //uid获取name
    public static Map<String, String> nameOfUid;

    //新朋友列表
    public static List<String> newFriendList=new ArrayList<>();


    // 全局唤醒
    public static void isConnect(){
        if (NettyThread.channel==null){
            getContext().stopService(new Intent(getContext(), MyNettyService.class));
            getContext().startService(new Intent(getContext(), MyNettyService.class));
        }
    }
}
